package com.面试题;

import java.util.*;
import java.util.stream.Collectors;

public class CheckSambel2 {


        public static void main(String[] args) {
            String target = "{[{()}]()[{()}]}";
            System.out.println(check(target));
        }



        public static boolean  check(String target){
            if (target.length()%2 !=0){
               return false;
            }
            List<String> list= Arrays.asList("()","[]","{}");
            for (String str:list) {
                if (target.contains(str)){
                    target= target.replace(str,"");
                }
                if (target.length()==0){
                    return true;
                }
            }
            if (target.length()>2){
              return check(target);
            }else{
                return list.contains(target);
            }

        }



}
